<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@taglib prefix="s" uri="strutsTags"%>
<%@taglib prefix="ty" uri="/wyzzTags"%>
<html>
	<head>		
		<!-- css修饰信息 -->
		<link href="<s:url value="/resource/css/style.css"/>" rel="stylesheet" type="text/css" />
		<jsp:include flush="true" page="/sitemesh/jsPackage.jsp"></jsp:include>
		<script type="text/javascript" src="../dwr/interface/HROT.js"></script>
		<script type="text/javascript" src="../resource/js/hrm/examin.js"></script>	
		<title>加班单修改并审批</title>
	</head>
	<body onload="init();">
	   	<s:component template="bodyhead">
		</s:component>
		<br/>
		<form id="addovertimerequest" name="addovertimerequest" method="POST" action="hrOtModifyAndApprove.action">

        	<!-- 隐藏字段 -->
			<s:hidden id="approveOper" name="approveOper" value="approve"></s:hidden>
			<s:hidden id="infoMeg" name="infoMeg" />
			<s:hidden id="srcAction" name="srcAction"/>
			<s:hidden id="gmanager" name="gmanager"/>
			<s:hidden id="orIdUp" name="orIdUp"/>
			<s:hidden id="otr.orTotalHours" name="otr.orTotalHours"></s:hidden>
			<s:hidden id="of_Bean.orEmpNo.id" name="of_Bean.orEmpNo.id"/>
			<s:hidden id="of_Bean.isTiaoxiu" name="of_Bean.isTiaoxiu"></s:hidden>
			
			<s:hidden id="otMatch" name="of_Bean.otMatch"/>
			<s:hidden id="errorMsg" name="of_Bean.errorMsg"/>
			<input type="hidden" id="startDate0" value="<s:date name="of_Bean.startDate0" format="yyyy-MM-dd HH:mm"></s:date>"/>
			<input type="hidden" id="endDate0" value="<s:date name="of_Bean.endDate0" format="yyyy-MM-dd HH:mm"></s:date>"/>
			<s:hidden id="totalHour0" name="of_Bean.totalHour0"/>
			<input type="hidden" id="startDate1" value="<s:date name="of_Bean.startDate1" format="yyyy-MM-dd HH:mm"></s:date>"/>
			<input type="hidden" id="endDate1" value="<s:date name="of_Bean.endDate1" format="yyyy-MM-dd HH:mm"></s:date>"/>
			<s:hidden id="totalHour1" name="of_Bean.totalHour1"/>
			<input type="hidden" id="startDate2" value="<s:date name="of_Bean.startDate2" format="yyyy-MM-dd HH:mm"></s:date>"/>
			<input type="hidden" id="endDate2" value="<s:date name="of_Bean.endDate2" format="yyyy-MM-dd HH:mm"></s:date>"/>
			<s:hidden id="totalHour2" name="of_Bean.totalHour2"/>

			<table width="100%">
			<tr>
			<td width="3%">
				<img src="../resource/images/h3Arrow.gif">
			</td>
			<td>
				<s:if test="scrAction == 'hrApprove'">
					<h3>加班申请备案</h3>
				</s:if>
				<s:else>
					<h3>加班申请确认</h3>
				</s:else>
			</td>
			</tr>
			</table>
			<table width="100%" class="formtable">
			<!--  showOtInfo -->
				<tr>							
					<td  align="left" nowrap="nowrap" width="10%" style="padding:6px 6px 6px 6px">
						员工编号：
					</td>
					<td align="left" >
						<s:property value="otr.orEmpNo.empDistinctNo" />
					</td>
			       <td  align="left" nowrap="nowrap" width="10%" style="padding:6px 6px 6px 6px">
						员工姓名：
					</td>
					<td align="left" nowrap="nowrap">
						<s:property value="otr.orEmpNo.empName"/>
					</td>
					<td  align="left" nowrap="nowrap" width="10%" style="padding:6px 6px 6px 6px">
						所在部门：
					</td>
					<td align="left">
						<s:property value="otr.orEmpDept.departmentName"/>
					</td>
				</tr>
				<tr>							
					
			       <td  align="left" nowrap="nowrap" width="10%" style="padding:6px 6px 6px 6px">
						加班单编号：
					</td>
					<td align="left" >
						<s:property value="otr.orNo"/>
					</td>
					<td  align="left" nowrap="nowrap" width="10%" style="padding:6px 6px 6px 6px">
						加班种类：
					</td>
					<td align="left" nowrap="nowrap">
						<s:property value="otr.orOtNo.otName"/>
					</td>
					 <td  align="left" nowrap="nowrap" width="10%" style="padding:6px 6px 6px 6px">
						当前状态：
					</td>
					<td align="left">
						<s:property value="of_Bean.otStatus" />
					</td>
				</tr>
				
				<tr>							
					<td align="left" nowrap="nowrap" width="10%" style="padding:6px 6px 6px 6px">
						加班开始时间：
					</td>
					<td align="left" >
						<s:date name="otr.orStartDate"  format="yyyy-MM-dd HH:mm" />
					</td>
			        <td  align="left" nowrap="nowrap" width="10%" style="padding:6px 6px 6px 6px">
						加班结束时间：
					</td>
					<td align="left"  nowrap="nowrap">
						<s:date name="otr.orEndDate"  format="yyyy-MM-dd HH:mm" />
					</td>
					<td  align="left" nowrap="nowrap" width="10%" style="padding:6px 6px 6px 6px">
						加班总时间：
					</td>
					<td align="left" >
						<s:property value="otr.orTotalHours" />&nbsp;小时
					</td>
				</tr>
				
				<tr>							
					<td  align="left" nowrap="nowrap" width="10%" style="padding:6px 6px 6px 6px">
						本月已批准加班：
					</td>
					<td align="left" nowrap="nowrap">
						<s:property value="of_Bean.usedTime" />小时
					</td>
					<td  align="left" nowrap="nowrap" width="10%" style="padding:6px 6px 6px 6px">
						加班理由：
					</td>
					<td align="left" colspan="3">
						<s:property value="otr.orReason" />
					</td>
				</tr>
			
			</table>
			<TABLE width="100%" class="formtable">
				<s:if test="otr.getOrEmpNo().getEmpShiftType() != 0">
					<tr>
						<td>加班刷卡匹配规则:</td>
						<td>
							<input type="radio" class="radio" name="otMatchRadio" <s:if test="of_Bean.otMatch==0">checked</s:if> value="0" onclick="changeOtMatch(this.value);" />按加班申请时间
							<input type="radio" class="radio" name="otMatchRadio" <s:if test="of_Bean.otMatch==1">checked</s:if> value="1" onclick="changeOtMatch(this.value);" />按实际刷卡时间
							<input type="radio" class="radio" name="otMatchRadio" <s:if test="of_Bean.otMatch==2">checked</s:if> value="2" onclick="changeOtMatch(this.value);" />两者取较小值
						</td>
					</tr>
				</s:if>
				<tr>
				    <td>
				        日期：
				    </td>
				    <td>				        
				        <s:textfield  id="date" name="of_Bean.orShiftDate" required="true" size="10" maxlength="10"/>
				         <img onclick="WdatePicker({el:'date'})" class="dateimg" src="../resource/js/My97DatePicker/skin/datePicker.gif">
				          <s:hidden id="of_Bean.orOvernight" name="of_Bean.orOvernight"/>
					      <input id="orOvernight" type="checkbox" class="checkbox" <s:if test="of_Bean.orOvernight==1">checked</s:if> onclick="hrm.examin.changeOvernight(this.checked);" />
					 		是否隔夜	
       			    </td>
       			<td rowspan="4">
       				    备注:
       			</td>
       			<td rowspan="4" colspan="3">
       				    <s:textarea id="of_Bean.orAppComment" name="of_Bean.orAppComment" cols="50" rows="4" required="true" onkeyup="if(this.value.length>255){this.value=this.value.substring(0, 255);}"/>
       			</td>
				</tr>
				<tr>
				      <td>
				        <label >开始时间<span class="required">*</span>:</label>
					  </td>
					  <td>
					      <s:select id="startTime" name="of_Bean.startTime" list="#{0:'0点',1:'1点',2:'2点',3:'3点',4:'4点',5:'5点',6:'6点',7:'7点',8:'8点',9:'9点',10:'10点',11:'11点',12:'12点',13:'13点',14:'14点',15:'15点',16:'16点',17:'17点',18:'18点',19:'19点',20:'20点',21:'21点',22:'22点',23:'23点'}" emptyOption="true" required="true"  />
					      <s:select id="startTimeMinute" name="of_Bean.startTimeMinute" list="#{0:'整',30:'半'}"	/>
					      <s:hidden id="of_Bean.startOvernight" name="of_Bean.startOvernight"/>
						  <span id="startTimeSpan" <s:if test="of_Bean.orOvernight!=1">style="display:none"</s:if>>
						  	<input type="checkbox" id="startOvernight" class="checkbox" <s:if test="of_Bean.startOvernight==1">checked</s:if> />
						   	隔夜  
						  </span>
					  </td>
				</tr>
				<tr>
					  <td>
					    <label >结束时间<span class="required">*</span>:</label>
					  </td>
					  <td>
					     <s:select id="endTime" name="of_Bean.endTime" list="#{0:'0点',1:'1点',2:'2点',3:'3点',4:'4点',5:'5点',6:'6点',7:'7点',8:'8点',9:'9点',10:'10点',11:'11点',12:'12点',13:'13点',14:'14点',15:'15点',16:'16点',17:'17点',18:'18点',19:'19点',20:'20点',21:'21点',22:'22点',23:'23点',24:'24点'}" emptyOption="true" required="true"  />
					     <s:select id="endTimeMinute" name="of_Bean.endTimeMinute" list="#{0:'整',30:'半'}"	/>
					     <s:hidden id="of_Bean.endOvernight" name="of_Bean.endOvernight"/>
					     <span id="endTimeSpan" <s:if test="of_Bean.orOvernight!=1">style="display:none"</s:if>>
					        <input type="checkbox" id="endOvernight" class="checkbox" disabled="disabled" checked="checked"/>
					                     隔夜
					     </span>
					  </td>
				</tr>
				<tr>
					  <td>
					    <label >是否调休<span class="required">*</span>:</label>
					  </td>
					  <td>
				          <s:if test="of_Bean.isTiaoxiu">
					          <input type="radio" class="radio" name="tiaoxiu" id="tiaoxiu1" value="0"  onclick="hideTiaoxiu();"/>否 
		                      <input type="radio" class="radio" name="tiaoxiu" id="tiaoxiu2" value="1" checked="checked" onclick="showTiaoxiu();"/>是
					     </s:if>
					     <s:else>
					          <input type="radio" class="radio" name="tiaoxiu" id="tiaoxiu1" value="0" checked="checked" onclick="hideTiaoxiu();"/>否 
		                      <input type="radio" class="radio" name="tiaoxiu" id="tiaoxiu2" value="1" onclick="showTiaoxiu();"/>是 
					     </s:else> 
					  </td>
				</tr>
				<tr>
		            <td>
		            <div id="div1"><label >调休时间：</label></div>
		                    
		            </td>
		            <td id="tiaoXiuTR" colspan="5" align="left">
		                <s:textfield id="of_Bean.orTiaoxiuHours" name="of_Bean.orTiaoxiuHours" value="%{otr.orTotalHours}" maxLength="6" size="6" onkeyup="value=value.replace(/[^\d \.]/g,'')"></s:textfield>小时
	                     	有效期至<s:textfield id="otTiaoxiuExpire" name="of_Bean.orTiaoxiuExpire" required="true" size="10" maxlength="10"/>
	                    <img onclick="WdatePicker({el:'otTiaoxiuExpire'})" class="dateimg" src="../resource/js/My97DatePicker/skin/datePicker.gif">								    																			
		            </td>
		         
		        </tr>
		        <tr><td></td></tr>
				<tr>
					<td height="1" colspan="4" align="center">						
							<input id="sub" name="sub" class="button" type="button" value="提交" onclick=" return submitOtRequest('approve');">	
							<input  type="reset" class="button" name="reset" value="重置">
					</td>
				</tr>
			</TABLE>
	<!--  showOtLogInfo!!! -->		
			<br>
			<s:if test="of_Bean.logList!=null && of_Bean.logList.size()>0">
			    <s:iterator value="of_Bean.logList">
				  <p align="left">
				   &nbsp;
				   <s:property value="%{slChangeEmpno.empName}" />于
						    <s:date name="slChangeTime" format="yyyy-MM-dd HH:mm:ss" />
						    <s:property value="%{slAction}" />
					        <s:if test="slComments!=null && slComments!='' && slComments.length>0">
					            &nbsp;备注信息：<s:property value="%{slComments}" />
					        </s:if>
					</p>       
		
			    </s:iterator>
			</s:if>
		</form>
<script type="text/javascript">
//提交或拒绝(公用方法)
function submitOtRequest(operate){
    var comm=document.getElementById("of_Bean.orAppComment").value;
    if(comm==null || comm==""){
        alert("备注信息不能为空！");
        return false;
    }
    if(comm.length>255){
        alert("备注信息太长，最长为255个字符！");
        return false;
    }
    if(!confirm("您确定要提交该条加班单吗？")){
        return false;
    }

    if(document.getElementById("orOvernight").checked){
		document.getElementById("of_Bean.orOvernight").value = 1; // 加班隔夜
		document.getElementById("of_Bean.endOvernight").value = 1; // 结束时间必定隔夜
		if (document.getElementById("startOvernight").checked)
			document.getElementById("of_Bean.startOvernight").value = 1; // 开始时间可能隔夜
		else
			document.getElementById("of_Bean.startOvernight").value = 0; // 开始时间不隔夜
	} else {
		document.getElementById("of_Bean.orOvernight").value = 0; // 加班不隔夜
		document.getElementById("of_Bean.startOvernight").value = 0; // 开始时间不隔夜
		document.getElementById("of_Bean.endOvernight").value = 0; // 结束时间不隔夜
	}
    
    var srcAction = document.getElementById("srcAction").value;
    if (srcAction == "hrConfirm") {
    	document.getElementById("addovertimerequest").action = "allOtModifyAndConfirm.action";
    }
    
    document.getElementById('approveOper').value = operate;
    document.getElementById("addovertimerequest").submit();
    return true;
}

function changeOtMatch(value) {
	var errorMsg = document.getElementById("errorMsg").value;
	if (errorMsg != "" && errorMsg.length > 0) {
		alert(errorMsg);
		return;
	}
	var startDateStr;
	var endDateStr;
	var totalHours;
	if (value == 0) {
		startDateStr = document.getElementById("startDate0").value;
		endDateStr = document.getElementById("endDate0").value;
		totalHours = document.getElementById("totalHour0").value;
	} else if (value == 1) {
		startDateStr = document.getElementById("startDate1").value;
		endDateStr = document.getElementById("endDate1").value;
		totalHours = document.getElementById("totalHour1").value;
	} else {
		startDateStr = document.getElementById("startDate2").value;
		endDateStr = document.getElementById("endDate2").value;
		totalHours = document.getElementById("totalHour2").value;
	}

	var startDate = startDateStr.substring(0,10);
	var endDate = endDateStr.substring(0,10);
	var startTime = parseInt(startDateStr.substring(11,13),10);
	var endTime = parseInt(endDateStr.substring(11,13),10);
	var startTimeMinute = parseInt(startDateStr.substring(14,startDateStr.length),10);
	var endTimeMinute = parseInt(endDateStr.substring(14,endDateStr.length),10);

	if (startDate == endDate) hrm.examin.changeOvernight(false);
	else hrm.examin.changeOvernight(true);
	
	document.getElementById("startTime").value = startTime;
	document.getElementById("startTimeMinute").value = startTimeMinute;
	document.getElementById("endTime").value = endTime;
	document.getElementById("endTimeMinute").value = endTimeMinute;
	document.getElementById("otr.orTotalHours").value = totalHours;
	document.getElementById("of_Bean.orTiaoxiuHours").value = totalHours;
}

/***对是否显示调休的文本框进行设置***/
function init(){
	var t=document.getElementById("of_Bean.isTiaoxiu").value;
    if(t=="true"){
        showTiaoxiu();
        var errorMsg = document.getElementById("errorMsg").value;
        if (errorMsg.trim() != "") alert(errorMsg);
    }else{
        hideTiaoxiu();
		document.getElementById("of_Bean.orTiaoxiuHours").value=document.getElementById("otr.orTotalHours").value;
		var orId = document.getElementById('orIdUp').value;
		HROT.getTiaoxiuExpire(orId, getExpireCallBack);
    }
}
function getExpireCallBack(expire){
    if(expire != null){
        document.getElementById("otTiaoxiuExpire").value = expire;
    }
    var errorMsg = document.getElementById("errorMsg").value;
    if (errorMsg.trim() != "") alert(errorMsg);
}

/**隐藏 调休时间 所在行***/
function hideTiaoxiu(){
     document.getElementById("tiaoXiuTR").style.display="none";
     document.getElementById("div1").style.display="none";
     document.getElementById("of_Bean.isTiaoxiu").value="false";
}
	    
/**显示 调休时间 所在行***/
function showTiaoxiu(){
    document.getElementById("tiaoXiuTR").style.display="block";
    document.getElementById("div1").style.display="block";
    document.getElementById("of_Bean.isTiaoxiu").value="true";
}
</script>  
</body>
</html>
